bug fix jobs controller

Judy Ngai 8 years ago
parent
commit
2c412ce56f
1 changed files with 5 additions and 5 deletions
  1. 5 5
      app/controllers/jobs_controller.rb

+ 5 - 5
app/controllers/jobs_controller.rb

@@ -16,10 +16,10 @@ class JobsController < ApplicationController
16 16
     respond_to do |format|
17 17
       if !running? && @job.destroy
18 18
         format.html { redirect_to jobs_path, notice: "Job deleted." }
19
-        format.json { render json: "", status: :ok }
19
+        format.json { head :no_content }
20 20
       else
21 21
         format.html { redirect_to jobs_path, alert: 'Can not delete a running job.' }
22
-        format.json { render json: "", status: :unprocessable_entity }
22
+        format.json { render json: @job.errors, status: :unprocessable_entity }
23 23
       end
24 24
     end
25 25
   end
@@ -34,7 +34,7 @@ class JobsController < ApplicationController
34 34
         format.json { render json: @job, status: :ok }
35 35
       else
36 36
         format.html { redirect_to jobs_path, alert: 'Can not enqueue a running job.' }
37
-        format.json { render json: "", status: :unprocessable_entity }
37
+        format.json { render json: @job.errors, status: :unprocessable_entity }
38 38
       end
39 39
     end
40 40
   end
@@ -53,7 +53,7 @@ class JobsController < ApplicationController
53 53
 
54 54
     respond_to do |format|
55 55
       format.html { redirect_to jobs_path, notice: "Failed jobs removed." }
56
-      format.json { render json: '', status: :ok }
56
+      format.json { head :no_content }
57 57
     end
58 58
   end
59 59
 
@@ -62,7 +62,7 @@ class JobsController < ApplicationController
62 62
 
63 63
     respond_to do |format|
64 64
       format.html { redirect_to jobs_path, notice: "All jobs removed." }
65
-      format.json { render json: '', status: :ok }
65
+      format.json { head :no_content }
66 66
     end
67 67
   end
68 68